<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <link
      href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.3.1/css/bootstrap.min.css"
      rel="stylesheet"
    />
    <style>
      /* 通过样式覆盖 修改轮播图的样式，将其设置居中显示，调整图片宽高 */
      .carousel {
        width: 800px;
        /* height: 400px; */
        margin: 0 auto;
      }
      .carousel-inner > .item > img {
        width: 800px;
        height: 400px;
      }
      /* 调整分页器的高度 */
      .carousel-indicators {
        bottom: 9px;
      }
    </style>
  </head>
  <body>
    <div
      id="carousel-example-generic"
      class="carousel slide"
      data-ride="carousel"
    >
      <!-- 分页器 -->
      <ol class="carousel-indicators">
        <li
          data-target="#carousel-example-generic"
          data-slide-to="0"
          class="active"
        ></li>
        <li data-target="#carousel-example-generic" data-slide-to="1"></li>
        <li data-target="#carousel-example-generic" data-slide-to="2"></li>
        <li data-target="#carousel-example-generic" data-slide-to="3"></li>
      </ol>

      <!-- 轮播组图及文字 -->
      <div class="carousel-inner" role="listbox">
        <div class="item active">
          <!-- 轮播图 -->
          <img src="images/1.jpg" alt="banner" />
          <!-- 轮播图上的文字 -->
          <div class="carousel-caption">
            <h3>图片标题</h3>
            <p>图片描述</p>
          </div>
        </div>
        <div class="item">
          <img src="./images/2.jpg" alt="banner" />
          <div class="carousel-caption">
            <h3>图片标题</h3>
            <p>图片描述</p>
          </div>
        </div>
        <div class="item">
          <img src="./images/3.jpg" alt="banner" />
          <div class="carousel-caption">
            <h3>图片标题</h3>
            <p>图片描述</p>
          </div>
        </div>
        <div class="item">
          <img src="./images/4.jpg" alt="banner" />
          <div class="carousel-caption">
            <h3>图片标题</h3>
            <p>图片描述</p>
          </div>
        </div>
      </div>

      <!-- 控制器 -->
      <a
        class="left carousel-control"
        href="#carousel-example-generic"
        role="button"
        data-slide="prev"
      >
        <span
          class="glyphicon glyphicon-chevron-left"
          aria-hidden="true"
        ></span>
        <span class="sr-only">Previous</span>
      </a>
      <a
        class="right carousel-control"
        href="#carousel-example-generic"
        role="button"
        data-slide="next"
      >
        <span
          class="glyphicon glyphicon-chevron-right"
          aria-hidden="true"
        ></span>
        <span class="sr-only">Next</span>
      </a>
    </div>
  </body>
  <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
  <script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.3.1/js/bootstrap.min.js"></script>
  <script>
    // 默认切换图片时间为5s，可以修改时间
    $(".carousel").carousel({
      interval: 3000,
    });
  </script>
</html>
